Repository navigation
[rmodels] Use the per-bone normal matrices in CPU skinning again - #6434
Merged
raysan5 merged 1 commit intoNov 21, 2026
Merged
Conversation
raysan5#6191 computes each bone's normal matrix once per update, but raysan5#5921 (merged later from an older branch) brought back the per-vertex `MatrixTranspose(MatrixInvert(...))` call when it switched the loop to `Mesh *`. Since then the normal matrices are computed and never used, and every skinned vertex inverts up to four 4x4 matrices again. Use `boneNormalMatrices[boneIndex]` in the vertex loop. The animated vertices and normals are bit-identical.
Owner
|
@b84330808 oh, good catch! thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#6191 made
UpdateModelAnimation()compute each bone's normal matrix once per update. #5921 was merged a week later from an older branch and, while switching the loop toMesh *, put the per-vertexMatrixTranspose(MatrixInvert(model.boneMatrices[boneIndex]))back. So right nowboneNormalMatricesis filled every update and never read, and every skinned vertex inverts up to 4 matrices again.This is the one-line fix: use
boneNormalMatrices[boneIndex]in the vertex loop.UpdateModelAnimation()time per call with the example models (default material, so CPU skinning), median of 7 alternating runs, Windows 11, i7-9700, zig cc -O2, GLFW + OpenGL 3.3:Animated vertices and normals are bit-identical before and after (hashed
animVertices/animNormals).